package controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import repositories.PersonRepository;

/**
 *
 * @author user38
 */
@Controller
public class WelcomeController {
    @Autowired
    private PersonRepository repository;

    public void setRepository(PersonRepository repository) {
        this.repository = repository;
    }
    
    @RequestMapping("/welcome")
    public ModelAndView index() {
        ModelMap map = new ModelMap();
        map.addAttribute("persons", repository.getPersons());
        
        return new ModelAndView("welcome", map);
    }
    
}
